package com.example.controller;

import com.example.enums.HotBusinessEnum;
import com.example.model.HotKeyModel;
import com.example.service.HotKeyService;
import com.example.utils.HotKeyUtils;
import com.example.utils.SerialNoUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 业务聚合
 *
 * @version [V2.0]
 * @package com.example.controller;
 * @description:[用一句话描述该文件做什么]
 * @author: [zhuben]
 * @date: [2024-01-31 17:37]
 * @copyright: 2024 echovin.com
 */
@RestController
public class IndexController {
    @Resource
    private HotKeyUtils hotKeyUtils;
    @Resource
    private HotKeyService hotKeyService;
    @Resource
    private SerialNoUtils serialUtils;
    @GetMapping("save")
    public ResponseEntity<?> save() throws Exception {
        HotKeyModel hotKeyModel1 = new HotKeyModel();
        hotKeyModel1.setBusinessType(HotBusinessEnum.DRUG.getType());
        hotKeyModel1.setBusinessId("f2400d20-f0e8-4db9-88ff-7fab6205e79f");
        hotKeyModel1.setStaffId("9999");
        hotKeyModel1.setHospitalId("f356489s7s8d4s55sd4s5d5");
        HotKeyModel hotKeyModel2 = new HotKeyModel();
        hotKeyModel2.setBusinessType(HotBusinessEnum.DRUG.getType());
        hotKeyModel2.setBusinessId("70669db7-aa05-4b88-b9e6-7444648e880a");
        hotKeyModel2.setStaffId("9999");
        hotKeyModel2.setHospitalId("f356489s7s8d4s55sd4s5d5");
        List<HotKeyModel> hotKeyModels = new ArrayList<>();
        hotKeyModels.add(hotKeyModel1);
        hotKeyModels.add(hotKeyModel2);
        hotKeyUtils.save(hotKeyModels);
        return ResponseEntity.ok("");
    }
    @GetMapping("list")
    public ResponseEntity<?> list(){
        List<String> hotKeyModels = hotKeyUtils.get("01", "9999", null, null, "f356489s7s8d4s55sd4s5d5");
        return ResponseEntity.ok(hotKeyModels);
    }

    @GetMapping("serialno")
    public ResponseEntity<?> serialNo(){
        String ordersSerialNo = serialUtils.serialNoByRedis("ORDERS_SERIAL_NO", 1);
        return ResponseEntity.ok(ordersSerialNo);
    }
}
